module Singly
  class Friends
    include Singly::Endpoint

    endpoint :get, "/friends", required: [:access_token], optional: [:data, :verify]

    def all(params={})
      group_endpoint(__method__, params)
    end

    def peers(params={})
      group_endpoint(__method__, params)
    end

    def ios(params={})
      group_endpoint(__method__, params)
    end

    def android(params={})
      group_endpoint(__method__, params)
    end

    def facebook(params={})
      group_endpoint(__method__, params)
    end

    def twitter(params={})
      group_endpoint(__method__, params)
    end

    def linkedin(params={})
      group_endpoint(__method__, params)
    end

    def gcontacts(params={})
      group_endpoint(__method__, params)
    end

    def instagram(params={})
      group_endpoint(__method__, params)
    end

    def foursquare(params={})
      group_endpoint(__method__, params)
    end

    def github(params={})
      group_endpoint(__method__, params)
    end

    def tumblr(params={})
      group_endpoint(__method__, params)
    end

    def flickr(params={})
      group_endpoint(__method__, params)
    end

    def yammer(params={})
      group_endpoint(__method__, params)
    end

    def klout(params={})
      group_endpoint(__method__, params)
    end

    private

    def group_endpoint(group, params)
      params ||= {}
      Singly::Friends::Group.new(creds.merge(params.merge({
        group: group.to_s
      })))
    end
  end
end